package com.ruoyi.system.controller;

import com.ruoyi.argument.CurrentUser;
import com.ruoyi.dto.DataWrapper;
import com.ruoyi.system.domain.Sign;
import com.ruoyi.system.domain.Student;
import com.ruoyi.system.dto.FaceSignParam;
import com.ruoyi.system.dto.LocationSignParam;
import com.ruoyi.system.service.SignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sign")
public class SignController {
    @Autowired private SignService signService;

    @PostMapping("/signWithLocation")
    @ResponseBody
    public DataWrapper<String> signWithLocation(@RequestBody LocationSignParam locationSignParam, @CurrentUser Student student) {
        this.signService.signWithLocation(locationSignParam,student);
        return DataWrapper.success();
    }

    @PostMapping("/signWithFace")
    @ResponseBody
    public DataWrapper<String> signWithFace(@RequestBody FaceSignParam locationSignParam, @CurrentUser Student student) {
        this.signService.signWithFace(locationSignParam,student);
        return DataWrapper.success();
    }

    @PostMapping("/list")
    @ResponseBody
    public DataWrapper<List<Sign>> list(@CurrentUser Student student) {
        List<Sign> list = this.signService.list(student.getStudentId());
        return DataWrapper.success(list);
    }
}
